<%@page pageEncoding="UTF-8"%>
<%@include file="/common/common.jsp"%>
<%@include file="/common/skins/skin0/component.jsp" %>
<h:css href="/css/style1/style-custom.css"/>
<html>
<!-- 
  - Author(s): pengweiling
  - Date: 2012-07-16 14:34:05
  - Description:
-->
<head>
<title>入账</title>
</head>
<body>

<form name="dataform" action="com.hms.OrderMgr.Account.flow" checkType="blur" target="_self" method="post" onsubmit="return checkAccount(this);">
<input type="hidden" name="_eosFlowAction" value="saveTrans">

<table align="center" border="0" width="100%" class="form_table">
            <tr>
              <td class="form_label" style="width:20%">
               消费项目
              </td>                          
              <td colspan="1" style="width:80%"> 
                    
      <l:equal property="_eosLastAccessAction" targetValue="account">
                <w:lookup style="width:200px;" 
                          lookupUrl="com.hms.commonPick.WeItemSelect.flow"
                          allowInput="false"
                          dialogTitle="选择入账科目"
                          displayProperty="itemCode"
                          property="itemCode"
                          onReturnFunc="handleItem"
                          name="bill/citemcode"
                />
                <h:hidden property="itemId" name="bill/iitemid"/>
      </l:equal>
      
      <l:equal property="_eosLastAccessAction" targetValue="saveTrans">
                <w:lookup style="width:200px;" 
                          lookupUrl="com.hms.commonPick.WeItemSelect.flow"
                          allowInput="false"
                          dialogTitle="选择入账科目"
                          displayProperty="bill/citemcode"
                          property="bill/citemcode"
                          readOnly="true"/>
                <h:hidden property="bill/iitemid"/>
      </l:equal>              

              </td>
             </tr>
            <tr>
              <td class="form_label" style="width:20%">
                项目名称
              </td>
              <td colspan="1" style="width:80%">
      <l:equal property="_eosLastAccessAction" targetValue="account">
         <h:text  property="itemDesc" style="width:200px;" name="bill/citemdesc" readonly="true" />
      </l:equal>
      
      <l:equal property="_eosLastAccessAction" targetValue="saveTrans">
         <h:text  property="bill/citemdesc" style="width:200px;" readonly="true"/>
      </l:equal>                                   
              </td>
             </tr>
             
            <tr>
              <td class="form_label" style="width:20%">
                客单
              </td>
              <td colspan="1" style="width:80%" >
      <l:equal property="_eosLastAccessAction" targetValue="account">
          <h:select name="bill/igresid"  style="width:200px;" property="gresId">
             <h:options property="gres" labelField="cgresno" valueField="igresid"/>
          </h:select>
      </l:equal>
      
      <l:equal property="_eosLastAccessAction" targetValue="saveTrans">
         <h:text  property="gres/cgresno" style="width:200px;" readonly="true"/>
      </l:equal>      
                    

              </td>
             </tr>
                 
            <tr>
              <td class="form_label" style="width:20%">
                消费金额
              </td>
              <td colspan="1" style="width:80%">
      <l:equal property="_eosLastAccessAction" targetValue="account">
          <h:text  style="width:200px;" property="bill/ndebit"/>
      </l:equal>
      
      <l:equal property="_eosLastAccessAction" targetValue="saveTrans">
         <h:text   style="width:200px;" readonly="true"   property="bill/ndebit"/>
      </l:equal>   
                    
                
              </td>
             </tr>
             
            <tr>
              <td class="form_label" style="width:20%">
                凭证编号
              </td>
              <td colspan="1" style="width:80%">
      <l:equal property="_eosLastAccessAction" targetValue="account">
          <h:text  style="width:200px;" property="bill/creferenceno"/>
      </l:equal>
      
      <l:equal property="_eosLastAccessAction" targetValue="saveTrans">
         <h:text  style="width:200px;" readonly="true"   property="bill/creferenceno" readonly="true"   />
      </l:equal>               
                
              </td>
             </tr>
             
            <tr>
              <td class="form_label" style="width:20%">
                备&nbsp;&nbsp;注
              </td>
              <td colspan="1" style="width:80%">
      <l:equal property="_eosLastAccessAction" targetValue="account">
          <h:textarea  style="width:100%"  property="bill/cdescription"/>
      </l:equal>
      
      <l:equal property="_eosLastAccessAction" targetValue="saveTrans">
         <h:textarea  style="width:100%"  readonly="true"   property="bill/cdescription" readonly="true"   />
      </l:equal>    
              </td>
             </tr>
                  
            <tr>
              <td class="form_label" align="center" colspan="2">
      <l:equal property="_eosLastAccessAction" targetValue="account">
          <input type="submit" class="button" value="保&nbsp;存">
      </l:equal>
      
      <l:equal property="_eosLastAccessAction" targetValue="saveTrans">
         <input type="button" class="button" value="继续新增" onclick="newAccount()">  
      </l:equal>               

<h:hidden property="bill/iorderid" name="orderId"/>
<h:hidden property="bill/igresid" name="gresId"/>
<h:hidden property="bill/dbusinessdate"/>

                <input type="button" class="button" value="关&nbsp;闭" onclick="window.close();">
              </td>
             </tr>                                 
          </table>
</form>          

<script>
  function newAccount(){
     $name("_eosFlowAction").value = "account";
     $name("dataform").submit();
     
  }
  
  function checkAccount(frm){
     try{
        var x = Number(trim($name("bill/ndebit").value));
        if (x <= 0){
           alert("入账金额必须为大于0!");
           return false;
        }
     }catch(e){
        alert("入账金额必须为大于0!");
        return false;
     }
     
     if (!trim($name("bill/iitemid").value)){
       alert("请选择入账科目!");
       return false;
     }
     
     $name("bill/dbusinessdate").value = dateToString(window.dialogArguments.convertFunc(new Date()));
     
     
     return true;
  }
  
  function handleItem(args){
     if (args){
       $name("bill/iitemid").value = args[0];
       args[0] = args[1];
       $name("bill/citemdesc").value = args[2];
     }
     return true;
  }
  
  <l:notEmpty property="bill/itransid">
     window.dialogArguments.loadFunc('<b:write property="bill/igresid"/>');
  </l:notEmpty>
  
</script>
</body>
</html>